@extends('home.lrf_layouts')
@section('body')
<body class="blue">
<div id="login-page" class="row">
    <div class="col s12 z-depth-6 card-panel">
        <form class="login-form" id="login-form">
            <div class="row">
                <div class="input-field col s12 center">
                    <img src="{{asset('assets/images/avatar.png')}}" alt="头像" width="30%" class="responsive-img valign profile-image-login">
                    <p style="margin-left: 60px;margin-right: 60px;" class="center login-form-text">输入注册信息，确保邮箱能收到邮件</p>
                </div>
            </div>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-social-person-outline prefix"></i>
                    <input id="username" value="" name="username" type="text" class="validate">
                    <label for="username" class="center-align">用户名</label>
                </div>
            </div>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-communication-email prefix"></i>
                    <input id="email" value="" name="email" type="email" class="validate">
                    <label for="email" class="center-align">邮箱</label>
                </div>
            </div>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-action-lock-outline prefix"></i>
                    <input value="" id="password" name="password" type="password" class="validate">
                    <label for="password">密码</label>
                </div>
            </div>
            <div class="row margin">
                <div class="input-field col s12">
                    <i class="mdi-action-lock-outline prefix"></i>
                    <input value="" id="password-again" name="password_r" type="password">
                    <label for="password-again">确认密码</label>
                </div>
            </div>
            <div class="row">
                <div class="input-field col s12">
                    <a onclick="register()" class="btn waves-effect waves-light col s12">立刻注册</a>
                </div>
                <div class="input-field col s12">
                    <p class="margin center medium-small sign-up">已经有了账号? <a href="{{url('login')}}">登录</a></p>
                </div>
            </div>
        </form>
    </div>
</div>

<script>
    function register(){
        var uname=$("#username").val();
        var pass=$("#password").val();
        var emai=$("#email").val();
        var pass_r=$("#password-again").val();
        if(pass_r!=pass){
            layer.msg('两次密码不一样',{icon:5})
        }
        if(uname=='' || pass=='' || pass_r=='' || emai==''){
            layer.msg('您有未填写项',{icon:5});
            return false;
        }else{
            $.post('{{url('register')}}',{'_token':'{{csrf_token()}}','username':uname,'password':pass,'email':emai},function(res){
                if(res.status==0){
                    layer.msg(res.msg);
                }else{
                    layer.msg(res.msg);
                }
            });
        }
    }


</script>
@endsection
